<template>
    <el-card class="box-card">
        <div slot="header" class="card-heaer">
            <span style="line-height: 36px;">学业中断报案信息</span>
            <el-button type="danger" style="float:right" @click="delect" v-if="newState=='新增'|| (newState=='待办任务' && isNewAdd)">删除</el-button>
        </div>
    
        <el-form ref="form" :model="fromlist[model].obj" :rules.sync="modelrules" label-width="180px">
    
            <el-form-item label="申请学业中断日期" prop="RI_ACADEMIC_TIME" >
               <el-date-picker v-model="fromlist[model].obj.RI_ACADEMIC_TIME" @change="timeGet" type="date" :disabled=" newState=='审核' || (newState=='追加' && !isNewAdd ) || (newState=='待办任务' && !newIsEditer )" placeholder="选择日期时间">
                </el-date-picker>
    
            </el-form-item>
    
            <el-form-item label="学业中断事由" prop="RI_ACADEMIC_REASON">
                 <el-select v-model="fromlist[model].obj.RI_ACADEMIC_REASON" placeholder="学业中断事由" :disabled=" newState=='审核' || (newState=='追加' && !isNewAdd ) || (newState=='待办任务' && !newIsEditer )" style="float:left; width:200px; padding-left:5px">
      <el-option label="被保险人身故" value="被保险人身故"></el-option>
      <el-option label="被保险人因为遭受严重身体伤害连续住院超过三十日,或被保险人由于医疗原因被送回境内" value="被保险人因为遭受严重身体伤害连续住院超过三十日,或被保险人由于医疗原因被送回境内"></el-option>
       <el-option label="被保险人直系亲属身故" value="被保险人直系亲属身故"></el-option>
    </el-select>  
    <span style="padding-left:10px" v-show="fromlist[model].obj.RI_ACADEMIC_REASON=='被保险人因为遭受严重身体伤害连续住院超过三十日,或被保险人由于医疗原因被送回境内'">
    (被保险人因为遭受严重身体伤害连续住院超过三十日,或被保险人由于医疗原因被送回境内)
    </span>      
            </el-form-item>
    
            <el-form-item label="详情描述(请提供学费缴纳证明、向学校申请中断学业的相关文件、学校退还的学费及其他相关资料)" prop="RI_ACADEMIC_DETAILS" >
                <el-input type="textarea" v-model="fromlist[model].obj.RI_ACADEMIC_DETAILS" :disabled=" newState=='审核' || (newState=='追加' && !isNewAdd ) || (newState=='待办任务' && !newIsEditer )"></el-input>
            </el-form-item>
    
            <el-form-item label="审核:" v-if="newState=='审核'|| ( newState=='追加'&& !isNewAdd)">
                <el-select placeholder="审核" v-model="fromlist[model].obj.RI_ACADEMIC_STATE" :disabled=" (newState=='审核' && oldState!='需审核') || (newState=='追加' && !isNewAdd ) ">
                    <el-option label="审核通过" value="审核通过"></el-option>
                    <el-option label="退回重新填写" value="需修改"></el-option>
                    <el-option label="拒赔" value="审核不通过"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="拒赔原因:" v-if="fromlist[model].obj.RI_ACADEMIC_STATE=='审核不通过'">
                <el-input type="textarea" v-model="fromlist[model].obj.RI_ACADEMIC_WHY" :disabled="newState!='审核'"></el-input>
            </el-form-item>
            <el-form-item label="修改原因:" v-if="fromlist[model].obj.RI_ACADEMIC_STATE=='需修改'">
                <el-input type="textarea" v-model="fromlist[model].obj.RI_ACADEMIC_WHY" :disabled="newState!='审核'"></el-input>
            </el-form-item>
        </el-form>
    </el-card>
</template>
<script>
import {
    mapState
} from 'vuex';
export default {
    data() {
        return {
            medical: this.$store.state.reportform.medical,
            oldState: this.$store.state.reportform.fromlist[this.model].obj.RI_ACADEMIC_STATE,
            showwhy: false,
            hospatialList: [],
            issuccess: false //是否通过
        }
    },
    props: {
        //对象
        model: {
            type: Number,
            default: 0
        },
        //状态2.0 新增 追加 待办任务
        newState: {
            type: String,
            default: "新增"
        },
        //状态2.0 代办任务中是否是需修改的 默认是true
        newIsEditer: {
            type: Boolean,
            default: true
        },
        //状态2.0 追加中是否是新增 默认是false 可以编辑
        isNewAdd: {
            type: Boolean,
            default: false
        },
        //对象约束
        modelrules: {
            type: Object,
            default: {}
        },

        //是否是审核
        ischeck: {
            type: Boolean,
            default: false
        }
    },
    // watch: {           
    //     'medical.RI_MEDICAL_STATE': 'checkchange'
    // },
    methods: {
        timeGet() {          
        
        },
        handleCurrentChange(val) {
            this.currentRow = val;
         
            if (val != null && val != {})
                this.medical.RI_MEDICAL_HLNAME = val.RECOMMENDHOSPITAL_ID;
          
        },
        delect() {
      
            if (this.model !== -1) {
                this.fromlist.splice(this.model, 1)
            }
        }
    },
    computed: mapState({
        // 箭头函数可使代码更简练
        // medical: state => state.reportform.medical,
        address: state => state.select.address,
        medicalrules: state => state.reportform.medicalrules,
        fromlist: state => state.reportform.fromlist
    }),
    activated() {
        //如果是审核
        var saleno;
        var that = this;
        if (!this.ischeck) {
            //数据置空
            saleno = JSON.parse(sessionStorage.getItem("ReportUser"))[0].SALEDETAILNO;
            that.$http.get("RecommendHospital/" + saleno).then(response => {
                var data = response.body;
                if (data.code == 1) {
                    that.hospatialList = data.result;
                } else {
                    that.$notify.error({
                        title: '失败',
                        message: '数据获取失败'
                    });
                }
            }, response => {
                that.$notify.error({
                    title: '网络错误',
                    message: '网络错误'
                });
            });
        }
        else {
            saleno = this.$route.query["sid"];
            setTimeout(function () {
                that.$http.get("RecommendHospital/" + saleno).then(response => {
                    var data = response.body;
                   
                    if (data.code == 1) {
                       
                        if (that.medical.RI_MEDICAL_HTYPE == "力众推荐") {

                            for (var i = 0; i < data.result.length; i++) {

                                if (data.result[i].RECOMMENDHOSPITAL_ID == that.medical.RI_MEDICAL_HLNAME) {
                                    that.hospatialList.push(data.result[i]);

                                    continue;
                                }
                            }

                        } else {
                           
                            that.hospatialList = data.result;
                        }

                    } else {
                        that.$notify.error({
                            title: '失败',
                            message: '数据获取失败'
                        });
                    }
                }, response => {
                    that.$notify.error({
                        title: '网络错误',
                        message: '网络错误'
                    });

                });
            }, 300);
        }
       
    }
}
</script>
